﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;
using FinanceCalculators;

namespace HomeBuyerTools
{
    public partial class BuyerTools : PhoneApplicationPage
    {
        public BuyerTools()
        {
            InitializeComponent();
        }
        private void Mortage_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Views/MortagePayment/MortagePayment.xaml", UriKind.Relative));
        }

        //private void Affordability_Click(object sender, RoutedEventArgs e)
        //{
        //    NavigationService.Navigate(new Uri("/Views/HomeAffordability/HomeAffordability.xaml", UriKind.Relative));
        //}

        private void Insurance_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Views/HomeInsurance/HomeInsurance.xaml", UriKind.Relative));
        }

        //private void TaxSaving_Click(object sender, RoutedEventArgs e)
        //{
        //    NavigationService.Navigate(new Uri("/Views/MortgageTaxSavings/MortagageTaxSaving.xaml", UriKind.Relative));
        //}

        private void ByTerms_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Views/CompareLoansByTerm/CompareLoansByTerm.xaml", UriKind.Relative));
        }

        private void ByRate_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Views/CompareLoansByRate/CompareLoansByRate.xaml", UriKind.Relative));
        }

        //private void Fixed_Click(object sender, RoutedEventArgs e)
        //{
        //    NavigationService.Navigate(new Uri("/Views/FixedVsAdjustable/FixedVsAdjustable.xaml", UriKind.Relative));
        //}

        //private void Rent_Click(object sender, RoutedEventArgs e)
        //{
        //    NavigationService.Navigate(new Uri("/Views/RentVSBuy/RentVSBuy.xaml", UriKind.Relative));
        //}


        private void ValueProjection_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Views/HomeValueProjection/HomeValueProjection.xaml", UriKind.Relative));
        }



        private void Home_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Views/HomeRentOrBuy/HomeRentOrBuy.xaml", UriKind.Relative));
        }

        private void Gain_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Views/GainOnSaleOfHome/GainOnSaleOfHome.xaml", UriKind.Relative));
        }


        private void Closing_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Views/ClosingCostAnalysis/ClosingCostAnalysis.xaml", UriKind.Relative));
        }

        private void HelpImage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        
        {
            SbHelp.Completed += new EventHandler(SbHelp_Completed);
        }

        void SbHelp_Completed(object sender, EventArgs e)
        {
            LoadBrowserTask("http://bit.ly/gpGImW");

        }

        private void facebookImage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
       
        {
            SbFacebook.Completed += new EventHandler(SbFacebook_Completed);
        }

        void SbFacebook_Completed(object sender, EventArgs e)
        {
            LoadBrowserTask("http://on.fb.me/eytwPa");
        }

        private void twitterImage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
             SbTwitter.Completed += new EventHandler(SbTwitter_Completed);
        }
        void SbTwitter_Completed(object sender, EventArgs e)
        {
            LoadBrowserTask("http://bit.ly/exHPzZ");
        }

        private void youtubeImage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            
            SbYoutube.Completed += new EventHandler(SbYoutube_Completed);
        }

        void SbYoutube_Completed(object sender, EventArgs e)
        {
            LoadBrowserTask("http://bit.ly/eYf4xG");
        }

        private void blogImage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            
            SbBlogger.Completed += new EventHandler(SbBlogger_Completed);
        }

        void SbBlogger_Completed(object sender, EventArgs e)
        {
            LoadBrowserTask("http://bit.ly/hpoWQX");
        }
        private void LoadBrowserTask(string url)
        {
            NavigationService.Navigate(new Uri("/Views/WebPage.xaml?url=" + url, UriKind.Relative));
        }

        private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (ListBox.SelectedIndex != -1)
            {
                int SelIndex = ListBox.SelectedIndex;
                ListBox.SelectedIndex = -1;
                switch (SelIndex)
                {
                    case 0:
                        //rate this app
                        MarketplaceReviewTask marketplaceReviewTask = new MarketplaceReviewTask();
                        marketplaceReviewTask.Show();
                        break;
                    case 1:
                        //share this app
                        EmailComposeTask emailcomposertask = new EmailComposeTask();
                        emailcomposertask.To = "";
                        emailcomposertask.Subject = "Activity Tracker App";
                        string lnk = "I have recently found a very good productivity app that I would like to share with you.\n";
                        lnk = lnk + "Below is the link of the app.\n\n\n";
                        lnk = lnk + "\n\n\nFrom Windows PC\n";
                        lnk = lnk + "http://social.zune.net/redirect?type=phoneApp&id=ebe21744-8623-e011-854c-00237de2db9e";
                        lnk = lnk + "From Windows Phone 7.\n";
                        lnk = lnk + "zune://navigate/?appID=ebe21744-8623-e011-854c-00237de2db9e";
                        emailcomposertask.Body = lnk;
                        emailcomposertask.Show();
                        break;
                    case 2:
                        //related apps
                        MarketplaceSearchTask marketplaceSearchTask = new MarketplaceSearchTask();
                        marketplaceSearchTask.SearchTerms = "lartsoft";
                        marketplaceSearchTask.Show();
                        break;
                    case 3:
                        //Feedback
                        NavigationService.Navigate(new Uri("/Views/Feedback.xaml", UriKind.Relative));
                        break;
                }
            }
        }



        private void Button_Click(object sender, RoutedEventArgs e)
        {

            NavigationService.Navigate(new Uri("/Views/Result/ResultPage.xaml?", UriKind.Relative));

        }

        

     }
}


        
        

    
